/*
package com.unhz.taigu.controller.file;


import com.unhz.generator.pojo.User;
import com.unhz.generator.utils.CommonFileAddress;
import com.unhz.generator.utils.ServerResponse;
import com.unhz.generator.utils.service.FileUtilService;
import com.unhz.taigu.service.InsoleImageService;
import com.unhz.taigu.service.file.FileManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;

import static org.apache.commons.codec.binary.StringUtils.newString;
*/
/**
 * 文件处理
 *//*

@Controller
@RequestMapping("/fileManagerController")
public class FileManagerController {

    */
/*@Autowired
    private LogService logService;
*//*

    */
/**图片判断参数**//*

    public static final int IMAGE = 1;

    */
/**音频判断参数**//*

    public static final int VOICE = 2;

    */
/**视频判断参数**//*

    public static final int VIDEO = 3;

    */
/**其他文件判断参数**//*

    public static final int FILE = 4;

    */
/**文件处理业务层**//*

    @Autowired
    private FileManagerService fileManagerService;

    */
/**文件工具上传处理业务层**//*

    @Autowired
    private FileUtilService fileUtilService;

*/
/*    @Autowired
    private SystemSetService systemSetService;*//*


    */
/**
     * 文件的保存
     * @param request 请求
     * @param insoleId 样品ID
     * @param userName 用户名
     * @param file 文件
     * @param reName  文件命名
     * @return
     *//*

    @RequestMapping("fileSave")
    public String fileSave(Model model,
                           HttpServletRequest request,
                            @RequestParam("insoleId") Integer insoleId,
                            @RequestParam("filename")MultipartFile file,
                            @RequestParam("reName") String reName,
                           HttpServletResponse response) throws IOException {
        User user = (User) request.getSession().getAttribute("user");
       // logService.insertMyBtLog("文件上传", "上传了文件信息", user.getUserName());
        String path = request.getSession().getServletContext().getRealPath("upload");
        String targetname = fileUtilService.upload(file,path);
        String fileNames = file.getOriginalFilename();
        String fileName = fileNames.substring(0,fileNames.lastIndexOf("."));
        String fileFormat = fileNames.substring(fileNames.lastIndexOf("."),fileNames.length());

            if (null == reName || "".equals(reName)) {
                reName = fileName;
            }
            //insertFile(userId, userName, CommonFileAddress.FilePath + "/" + targetname, reName, fileFormat);
            insertFile(insoleId, systemSetService.selectOne().getFilePath() + "/" + targetname, reName, fileFormat);

       // List<BTFile> files = fileManagerService.selectAll(userName);
        //model.addAttribute("files", files);
        return "bite/file/index.jsp";
    }

    */
/**
     * 以何种形式保存的方法
     * @param userId 用户ID
     * @param userName 用户名
     * @param fileUrl 文件url
     * @param fileName 文件名
     * @param fileFormat 文件后缀格式
     *//*

    public void insertFile(@RequestParam("insoleId") Integer insoleId, @RequestParam("userName") String userName, String fileUrl, @RequestParam("reName") String fileName, String fileFormat){
        //Dict dict = dictService.selectByFileFormat(fileFormat);
        int dictFormat = dict.getDictFormat();
        switch (dictFormat){
            case IMAGE:
                //图片进入
                save(insoleId,fileUrl,fileName,fileFormat,IMAGE);
                break;
            case VOICE:
                //音频进入
                save(insoleId,fileUrl,fileName,fileFormat,VOICE);
                break;
            case VIDEO:
                 //视频进入
                save(insoleId,fileUrl,fileName,fileFormat,VIDEO);
                break;
            case FILE:
                //文件进入
                save(insoleId,fileUrl,fileName,fileFormat,FILE);
                break;
            default:
        }
    }


    */
/**
     * 文件保存
     * @param userId 用户ID
     * @param fileUrl 文件url
     * @param fileName 文件名
     * @param fileFormat 文件后缀格式
     * @return
     *//*

    public void save(Integer insoleId,
                     String fileUrl,
                     String fileName,
                     String fileFormat,int type){
        List<BTFile> list = fileManagerService.selectByUserId(insoleId,type);
        BTFile files = new BTFile();
        for(BTFile file : list) {
            String fileStyle = file.getFileStyle();
            String name = file.getFileName();
            Integer id = file.getId();
            if (fileStyle.equals(fileFormat) && name.equals(fileName)) {
                return;
            }
        }
        files.setUserId(userId);
        files.setFileName(fileName);
        files.setFileStyle(fileFormat);
        files.setFileUrl(fileUrl);
        files.setFileType(type);
        fileManagerService.insertFile(files);
    }


*/
/*    @RequestMapping("deleteFile")
    @ResponseBody
    public int deleteFile(@RequestParam(value = "id") Integer id){
        int count = fileManagerService.deleteFile(id);
        return count;
    }*//*


}


*/
